package org.advanced.reflection;


/**
 * @author John.zhang
 * @version Id: Constructor, v 1.0 2020/12/3 20:26 ZhiYong Exp $
 */
public class Constructor {


    public static void main(String[] args) throws Exception {
        Class<User> userClass = User.class;
        java.lang.reflect.Constructor<?>[] constructors = userClass.getConstructors();

        java.lang.reflect.Constructor<?>[] declaredConstructors = userClass.getDeclaredConstructors();

        //1.直接创建
        User user = userClass.newInstance();
        //2.Constructor
        java.lang.reflect.Constructor<User> declaredConstructor = userClass.getDeclaredConstructor(String.class, String.class);
        declaredConstructor.setAccessible(true);
        declaredConstructor.newInstance("", "");


    }
}
